<template>
  <div class="details wrap">
    <main>
      <div class="content">
        <div class="l">
          <div class="bigImg">
            <img
              :src="
                currentImg == null
                  ? goods.smallImg[0]
                  : goods.smallImg[currentImg]
              "
              width="440"
              height="440"
              alt=""
            />
          </div>
          <ul>
            <li
              v-for="(item, index) in goods.smallImg.slice(0, 4)"
              :key="index"
            >
              <img
                @mouseenter="hoverImg(index)"
                :src="item"
                width="100"
                height="100"
                alt=""
              />
            </li>
          </ul>
        </div>
        <div class="r">
          <div class="top">
            <h2>
              {{ goods.name }}
            </h2>
            <p>{{ goods.seriesSubTitle }}</p>
            <div class="score">{{ goods.coin }}金币</div>
          </div>
          <div class="down">
            <section>
              <strong>选择样式</strong>
              <ul>
                <li
                  :tabindex="index"
                  v-for="(item, index) in goods.sku"
                  class=""
                  :key="index"
                >
                  {{ item }}
                </li>
              </ul>
            </section>
            <div style="margin: 10px 0">
              <strong>数量 <span>*礼品库存99件</span></strong>
              <div class="step">
                <el-input-number
                  v-model="num"
                  :min="1"
                  :max="10"
                ></el-input-number>
              </div>
            </div>
            <div class="btns">
              <div class="addToCart" @click="addToCart">加入购物车</div>
            </div>
            <div>
              <el-button
                type="text"
                @click="dialogTableVisible = true"
                class="buyNow"
              >
                立即购买
              </el-button>
              <el-dialog title="付款" :visible.sync="dialogTableVisible">
                <img
                  src="@/assets/img/收款.jpg"
                  alt=""
                  style="width: 300px; height: 300px"
                />
                <img
                  src="@/assets/img/zfb收款.jpg"
                  alt=""
                  style="width: 300px; height: 300px"
                />
              </el-dialog>
            </div>
          </div>
        </div>
      </div>
    </main>

    <el-tabs type="card" v-model="activeName">
      <el-tab-pane label="礼品详情" name="first">
        <div class="imgDetail">
          <img
            :src="item"
            v-for="(item, index) in goods.detailImg"
            :key="index"
          />
        </div>
      </el-tab-pane>
      <el-tab-pane label="常见问题" name="second">
        <div class="issue">
          <h4>兑换后运费如何收取？</h4>
          <p>
            商城内大部分实物产品均可包邮，也支持上门自提。虚拟产品则无需运费，可在兑换后直接使用。
          </p>
          <p class="mb20">
            （注：新疆，西藏，内蒙古，青海，海南，宁夏暂不支持包邮，在此地区兑换商品需提前与客服确认运费。）
          </p>
          <h4>如何申请退换货？</h4>
          <p>所有产品均为金币兑换礼品，无质量问题不支持退换货；</p>
          <p>如因喜好不同，或到货后后悔等原因，不支持退货；</p>
          <p>
            因客户原因如联系方式有误、电话停机、不接电话、无理由拒收等造成快件无法正常签收的情况，启明商城均不进行补发或赔付；
          </p>
          <p>
            如因质量问题需要退货，将由客服人员与客户联系，确认邮寄地址与流程。退回物品不得有人为损坏或使用痕迹，否则拒绝退换；
          </p>
          <p class="mb20">
            如顾客选择自行寄回商品，请先垫付运费，到货验证商品后，叩丁狼将以鸡腿发放形式为用户报销运费，不接受单方面到付件。
          </p>
          <h4>关于金币价格问题</h4>
          <p class="mb20">
            因可能存在系统缓存、页面更新延迟等不确定性情况，导致价格显示异常，商品具体售价请以订单结算页价格为准。如您发现异常情况出现，请立即联系我们补正，以便您能顺兑换。
          </p>
          <h4>联系我们</h4>
          <p>15555978129</p>
          <p class="mb20">微信搜索“15555978129”</p>
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import { mapActions} from "vuex";
export default {
  data() {
    return {
      num: 1,
      productInfo: null,
      goods: [],
      currentImg: null,
      activeName: "first",
      dialogTableVisible: false,
      dialogFormVisible: false,
      form: {
        name: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
      },
      formLabelWidth: "120px",
    };
  },
  methods: {
    ...mapActions({
      asyncchangeIsShowToast:"toastStatus/asyncchangeIsShowToast"
    }),
    hoverImg(index) {
      this.currentImg = index;
    },
    addToCart() {
      const goods = {};
      goods.name = this.goods.name;
      goods.jiage = this.goods.coin;
      goods.img = this.goods.Img;
      goods.id = this.goods.id;
      goods.goodsnum = 1;
      this.$store.commit("addToCart", goods);
      this.asyncchangeIsShowToast({
        msg:"加入购物车成功，请继续购买!!",
        type:"success"
      });
    },
  },
  created() {
    document.documentElement.scrollTop = 0;
    const paramsData = this.$route.query.goodsData;
    // console.log(paramsData);
    this.goods = paramsData;
    // console.log("shuju ");
    // console.log(goods);
  },
};
</script>
 
<style lang = "less" scoped>
@import "../assets/css/global.less";

.details {
  main {
    margin-bottom: 52px;
    display: flex;
    .content {
      width: 884px;
      display: flex;
      justify-content: space-between;
      .l {
        .bigImg {
          width: 459px;
          height: 440px;
          // background-color: #fcf;
          margin-bottom: 21px;
        }
        ul {
          width: 459px;
          display: flex;
          // flex-direction: row;
          justify-content: left;
          li {
            width: 100px;
            height: 100px;
            background-color: #cff;
            cursor: pointer;
            margin: 0 5px;
            img {
              filter: brightness(75%);
            }
            &:hover {
              img {
                filter: brightness(100%);
              }
            }
          }
        }
      }
      .r {
        padding: 7px 49px 0 31px;
        .top {
          padding-bottom: 23px;
          border-bottom: 1px solid #ececec;
          h2 {
            font-size: 28px;
            color: #000000;
          }
          p {
            margin-top: 15px;
            font-size: 14px;
            font-weight: 300;
            color: #999999;
          }
          .score {
            font-size: 28px;
            font-weight: bold;
            color: #fd604d;
            margin-top: 26px;
          }
        }
        .down {
          padding-top: 19px;
          strong {
            font-weight: 300;
            color: #000000;
            margin-bottom: 14px;
            display: block;
            span {
              color: #666;
              font-size: 14px;
            }
          }
          ul {
            width: 100%;
            overflow: hidden;
            li {
              padding: 5px 10px;
              cursor: pointer;
              height: 32px;
              float: left;
              text-align: center;
              line-height: 32px;
              color: #666666;
              border: 1px solid #d1d1d1;
              margin-right: 20px;
              margin-bottom: 11px;
            }
            li:focus {
              border-color: @base-color;
              color: @base-color;
              background-color: orange;
            }
          }
          .step {
            background: #fff;
            // width: 106px;
            margin-bottom: 24px;
            height: 32px;
            display: flex;
            justify-content: space-between;
            .reduce,
            .add {
              width: 30px;
              text-align: center;
              line-height: 32px;
              height: 32px;
              cursor: pointer;
              box-sizing: border-box;
              border: 1px solid #ccc;
              user-select: none;
            }
            input {
              width: 46px;
              height: 32px;
              user-select: none;
              border: 0;
              box-sizing: border-box;
              border-top: 1px solid #ccc;
              padding: 0;
              text-indent: 1.5em;
              outline: none;
              border-bottom: 1px solid #ccc;
            }
          }
          .btns {
            display: flex;
            margin-bottom: 25px;
            div {
              width: 150px;
              height: 46px;
              line-height: 46px;
              text-align: center;
              margin-right: 19px;
              cursor: pointer;
              color: #fff;
              &.addToCart {
                background: #3dc36b;
              }
              // &.buyNow {
              //   background: #fd604d;
              // }
            }
          }
          .love_share {
            display: flex;
            .love {
              display: flex;
              align-items: center;
              padding-right: 16px;
              border-right: 1px solid #666;
              img {
                margin-right: 12px;
              }
              span {
                color: #666666;
              }
            }
            .share {
              padding-left: 18px;
            }
          }
        }
      }
    }
    aside {
      padding-left: 19px;
      box-sizing: border-box;
      width: 230px;
      border-left: 1px solid #ddd;
      h3 {
        font-size: 18px;
        color: #333333;
        margin-bottom: 20px;
      }
      ul {
        li {
          margin-bottom: 30px;
          display: flex;
          cursor: pointer;
          justify-content: space-between;
          .l {
            width: 80px;
            height: 80px;
            margin-right: 10px;
            background-color: #ffc;
            img {
              width: 100%;
              display: block;
              border: 1px solid transparent;
            }
          }
          .r {
            width: 140px;
            display: flex;
            justify-content: space-around;
            flex-direction: column;
            .title {
              /* 超出一行变省略号 */
              text-overflow: ellipsis;
              width: 100%;
              font-weight: bold;
              overflow: hidden;
              white-space: nowrap;
              font-size: 14px;
              color: #666666;
            }
            .score {
              color: #666666;
              span {
                font-weight: bold;
                font-size: 18px;
                color: #ff5e0f;
              }
            }
          }
          &:hover {
            img {
              border: 1px solid @base-color;
            }
            .title {
              color: @base-color;
            }
          }
        }
      }
    }
  }
  .tabs {
    border-top: 1px solid #ececec;
    display: flex;
    width: 100%;
    margin-bottom: 27px;
    li {
      width: 120px;
      height: 50px;
      cursor: pointer;
      background: #fff;
      text-align: center;
      line-height: 50px;
      &.active {
        background: #ececec;
        font-weight: bold;
      }
    }
  }
}
.issue {
  padding-bottom: 40px;
  h4 {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
    margin-top: 20px;
  }
  p {
    line-height: 1.4em;
  }
}
.imgDetail {
  display: flex;
  width: 50%;
  flex-direction: column;

  img {
    width: 900px;
  }
}
.buyNow {
  color: white;
  background-color: orange;
  width: 150px;
              height: 46px;
}
</style>